<script setup>
    import { NList, NListItem, NButton, NCard, NText, NTooltip, NSwitch } from "naive-ui";
    import { usePreferenceStore } from "../../../../stores/preference";
    import { SetDefaultGameDirectory } from "../../../../wailsjs/go/preference/Preference";
    import { GetAllVersionsFromGameDir } from "../../../../wailsjs/go/launch/Version";
    import { useLaunchStore } from "../../../../stores/launch";

    const pref = usePreferenceStore()
    const laun = useLaunchStore()

    async function changeGameDir() {
        pref.defaultGameDir = await SetDefaultGameDirectory()

        const versionsList = await GetAllVersionsFromGameDir(pref.defaultGameDir)

        laun.versionLists = []
        for (let versionListItem of versionsList) {
            laun.versionLists.push({
                label: versionListItem,
                value: versionListItem
            })
        }
    }
</script>

<template>
    <NCard :bordered="false" embedded>
        <template #header>
            <NText :strong="true" :depth="3">
                游戏
            </NText>
        </template>

        <NList hoverable :show-divider="false">
            <NListItem>
                <template #suffix>
                    <NButton text size="large" @click="changeGameDir">
                        <NText :depth="3" underline>
                            {{ pref.defaultGameDir }}
                        </NText>
                    </NButton>
                </template>

                <NTooltip trigger="hover" placement="top-start" :keep-alive-on-hover="false">
                    <template #trigger>
                        <NButton text size="large">游戏目录</NButton>
                    </template>
                    fuck
                </NTooltip>
            </NListItem>
        </NList>
    </NCard>
</template>